package com.xuxiang.cloud.service;

import net.devh.boot.grpc.client.interceptor.GlobalClientInterceptorConfigurer;
import net.devh.boot.grpc.server.interceptor.GlobalServerInterceptorConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * @author xuxiang 2019/5/30 22:13
 */
@Order(Ordered.LOWEST_PRECEDENCE)
@Configuration
public class InterceptorConfiguration {

    @Bean
    public GlobalServerInterceptorConfigurer globalServerInterceptorConfigurer() {
        return registry -> registry.addServerInterceptors(new LogServerInterceptor());
    }

    @Bean
    public GlobalClientInterceptorConfigurer globalClientInterceptorConfigurer() {
        return registry -> registry.addClientInterceptors(new LogClientInterceptor());
    }

}
